package com.foogui.primary.communication;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(6);
        for (int i = 0; i < 5; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"号线程执行完毕");
                latch.countDown();
            },i+"").start();
        }

        latch.await(5,TimeUnit.SECONDS);
        System.out.println("main线程执行完毕");



    }
}
